import Vue from 'vue';
import vuex from 'vuex';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './app.vue';
import router from './views/route/route.js'
import JsonViewer  from 'vue-json-viewer'
// var history = require('connect-history-api-fallback');
import moment from 'moment'
import axios from "axios"
import BaiduMap from 'vue-baidu-map'
 
Vue.use(BaiduMap, {
  /* Visit http://lbsyun.baidu.com/apiconsole/key for details about app key. */
  ak: '6trUTb7Z7zgL5PHvk3LIy5t639xXaovh'
})
// 定义全局过滤器--时间格式化
axios.defaults.withCredentials = true;
 Vue.prototype.$axios = axios;
Vue.filter('format', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
    return moment(dataStr).format(pattern)

})
Vue.use(JsonViewer)
Vue.use(vuex);
Vue.use(ElementUI);
// Vue.use(History);
// const history = new History({});
// history({
//     rewrites: [
//       { from: /\//, to: '/index'},
//       { from: null, to: '/index'},
//     ]
//   });
const store =new vuex.Store({
    state:{
        count:0
    },
    mutations:{
        increment(state) {
            state.count++
        },
        decrease (state) {
            state.count--
        }
    }
})
router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
      document.title = to.meta.title
    }
    next()
  })
new Vue({
    el: '#app',
    router,
    store,
    render: h =>{
        return  h(App)
    }
});